<?php
    core::checkSession();
?>

<script type="text/javascript">
    $(document).ready(function(){
        $('#edit_profile_form').dialog({
            'autoOpen':false,
            'width':400,
            'height':300,
            'resizable':false,
            'modal':true
        });
        $('#show_edit_profile_form').click(function(){
            $('#edit_profile_form').dialog('open');
        });
        $('#image_avatar').change(function(){
            var image = $(this).val();
            $.post('~user/updateAvatar',{ image : image},function(data){

            });
        });
    });
</script>

<div style="position:relative;margin-top:70px;">
    <div class="profile_left_content">
        <div class="image_wapper">
            <?php
                if(isset($_SESSION['username']) && $_SESSION['username'] == $template->get('sId'))
                {
                    $aParams = array(
                        'id' => 'image_avatar',
                        'isEdit' => true,
                    );
                }
                if($template->get('image'))
                {
                    $aParams['image'] = 'upload/'.$template->get('image');
                }
                includeBlock('block/uploadBlock', $aParams);
            ?>
        </div>
        <a href="<?php echo URL::getLink('product/Manager'); ?>" class="profile_left_item green_metro_style"><i class="fa fa-laptop"></i><span>Product Manage</span></a>
        <a class="profile_left_item orange_metro_style"><i class="fa fa-cogs"></i><span>Settings</span></a>
        <a href="<?php echo URL::getLink('user/view/'.$template->get('username')); ?>" class="profile_left_item blue_metro_style"><i class="fa fa-shopping-cart"></i><span>My Page</span></a>
    </div>
    <div class="profile_content">
        <div class="profile_title"><i style="font-size:48px;" class="fa fa-heart-o"></i> <?php echo $template->get('fullname'); ?>
            <div class="profile_control">
                <button class="flat_metro_button green_metro_style"><i class="fa fa-pencil"></i> Edit Profile</button>
            </div>
        </div>
        <div class="profile_content_left">
            <h1 class="profile_content_title">About <?php echo $template->get('fullname'); ?></h1>
            <table style="width: 100%;">
                <tr>
                    <td style="width: 100px;">Fullname</td>
                    <td><?php echo $template->get('fullname'); ?></td>
                </tr>
                <tr>
                    <td>Location</td>
                    <td><?php echo $template->get('address'); ?></td>
                </tr>
                <tr>
                    <td>Email</td>
                    <td><?php echo $template->get('email'); ?></td>
                </tr>
                <tr>
                    <td>Link profile</td>
                    <td><a href="<?php echo URL::getLink('profile/id/'.$template->get('username')); ?>" style="color: #4a8bc2"><?php echo URL::getLink('profile/id/'.$template->get('username')); ?></a></td>
                </tr>
            </table>
        </div>
        <div class="profile_content_right">
            <div style="background-color:#e8697e;height:100px;color:#FFF;line-height: 100px;padding-left:20px;font-size:18px;">Follow Users <span class="profile_number_follow_user"><?php echo ($template->get('aUserFollows') ? count($template->get('aUserFollows')) : 0);?> <i class="fa fa-user"></i></span></div>
            <div class="profile_user_follow_area">
                <?php
                    if($template->get('aUserFollows'))
                    {
                        foreach($template->get('aUserFollows') as $uri => $aUser)
                        {
                            echo '<a class="profile_user_follow_item" href="'.$uri.'"><img src="'.URL::getLink('upload/'.$aUser['image']).'"><span>'.$aUser['fullname'].'</span></a>';
                        }
                    }
                ?>
                <div style="clear: both;"></div>
            </div>
        </div>
    </div>
    <div style="clear: both;"></div>
</div>
